package com.yiren.dbaa.util;

import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;

import com.yiren.backstage.currency.constant.HostDeviceModelConstant;
import com.yiren.dbaa.view.dialog.CustomDialog;

import org.apache.commons.lang.StringUtils;


/**
 * 类描述：   判断当前设备是手机还是平板
 */
public class CustomerServiceUtil {

    public static CustomDialog.Builder toPrompting;

    /**
     * 判断当前设备是手机还是平板，代码来自 Google I/O App for Android
     *
     * @return 平板返回 True，手机返回 False
     */
    public static boolean isPad(Context context) {
        return (context.getResources().getConfiguration().screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE;
    }

    /**
     * 判断当前设备是不是我司电脑（车机、工业电脑），代码来自 Google I/O App for Android
     *
     * @return 是返回 True，否返回 False
     */
    public static boolean isCarMachine(Context context) {
        String model = android.os.Build.MODEL;
        return StringUtils.isNotEmpty(model) && (model.contains(HostDeviceModelConstant.FYT6025) || model.equals(HostDeviceModelConstant.T3) || model.equals(HostDeviceModelConstant.SL8541) || model.equals(HostDeviceModelConstant.EVB3561SV) || model.contains(HostDeviceModelConstant.B906) || model.contains(HostDeviceModelConstant.AD101J) || model.contains(HostDeviceModelConstant.LEN6737M) || model.contains(HostDeviceModelConstant.AM83500) || model.contains(HostDeviceModelConstant.SL8541E));
    }

    /**
     * 判断是否是公司新的自研的工业电脑和车机
     *
     * @return 是返回 True，否返回 False
     */
    public static boolean isNewZyCarMachine(Context context) {
        String model = android.os.Build.MODEL;
        return StringUtils.isNotEmpty(model) && (model.contains(HostDeviceModelConstant.SL8541E));
    }

    /**
     * 平板给出温馨提示
     *
     * @param message 自定义显示内容
     */
    public static void toPrompting(final Context context, String message) {
        if (null == toPrompting) {
            toPrompting = new CustomDialog.Builder(context);
            toPrompting.setMessage(message);
            toPrompting.setTitle("温馨提示");
            toPrompting.setCanceled(false);
            toPrompting.setPositiveButton("我知道了", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    toPrompting = null;
                    dialog.dismiss();
                }
            });
            toPrompting.create().show();
        }
    }


}